package com.supermap.dataservice.agrinfo;

import com.supermap.dataservice.agrinfo.dao.AgrpraiseDao;
import com.supermap.dubbo.api.agrinfo.entity.Agrpraise;
import com.supermap.dubbo.api.agrinfo.AgrpraiseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.dubbo.config.annotation.Service;

import javax.annotation.Resource;

/**
 * @author lxs
 * @Title:
 * @Description:
 * @date 2018/3/8  16:49
 */
@Service
public class AgrpraiseServiceImpl implements AgrpraiseService {
    /**
     *使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类
     */
    protected static final Logger logger = LoggerFactory.getLogger(AgrpraiseServiceImpl.class);

    @Resource
    private AgrpraiseDao agrpraiseDao;
    @Override
    public int getAgrpraiseCount(int agrInfoId) {
        return agrpraiseDao.getAgrpraiseCount(agrInfoId);
    }

    @Override
    public boolean getPraise(int  userId, int  agrInfoId) {
        String a=agrpraiseDao.getPraise(userId,agrInfoId);
        if(a==null){
            return true;
        }
        return false;
    }

    @Override
    public boolean addAgrpraise(Agrpraise agrpraise) {
        String a= agrpraiseDao.getPraise(agrpraise.getUserId(),agrpraise.getAgrInfoId());
       if(a==null ){
           int a1=agrpraiseDao.addAgrpraise(agrpraise);
           if(a1==1){
               return true;
           }
           return false;
       }else {
           int a2=agrpraiseDao.delAgrById(agrpraise.getUserId(),agrpraise.getAgrInfoId());
           return  false;
       }
    }

}
